import request from '@/utils/request'

const getVisitorsList = (page, limit, key) => {
  return request('/visitor/list', {
    method: 'get',
    params: {
      page,
      limit,
      key
    }
  })
}

const getVisitorsListByFuzzyQuery = (page, limit, key) => {
  return request('/visitor/listByFuzzyQuery', {
    method: 'get',
    params: {
      page,
      limit,
      key
    }
  })
}

const deleteVisitorsList = (visitorIdCards) => {
  return request('/visitor/delete', {
    method: 'post',
    data: {
      visitorIdCards
    }
  })
}

const getVisitorById = (visitorId) => {
  return request({
    url: `/visitor/info/${visitorId}`,
    method: 'get'
  })
}

const saveOrUpdateVisitor = (visitorId, visitor) => {
  return request(`/visitor/${!visitorId ? 'save' : 'update'}`, {
    method: 'post',
    data: visitor
  })
}

export { getVisitorsList, getVisitorsListByFuzzyQuery, deleteVisitorsList, getVisitorById, saveOrUpdateVisitor }
